package leetcodecompetition.S100;

public class T6323 {
    public int distMoney(int money, int children) {
        if (money<children)return -1;
        if (money<=children+6)return 0;
        int a=(money-children)/7;
        int diff=(money-children)%7;
        if (a>children||a==children&&diff>0)return children-1;
        int b=children-a;
        if (b==1&&diff==3)return a-1;
        return a;
    }
}
